package com.spring.cloud.examples.controller;

import com.spring.cloud.examples.feign.ServerInfoApi;
import com.spring.cloud.examples.vo.TestPostVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

@Controller
public class CustomerController {

    @Autowired
    private RestTemplate restTemplate;


    @Autowired
    private ServerInfoApi serverInfoApi;

    @RequestMapping("/server_info")
    @ResponseBody
    public String serverInfo()
    {
        return serverInfoApi.port();
    }


    @RequestMapping(value="/test_post",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String testPost(@RequestBody TestPostVo testPostVo)
    {
        return serverInfoApi.testPost(testPostVo);
    }
}
